home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 17YHJBW (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  2.2 KB  |  56 lines

  1. package com.sun.java.swing.plaf.metal;
  2.  
  3. import com.sun.java.swing.AbstractListModel;
  4. import com.sun.java.swing.ComboBoxModel;
  5. import com.sun.java.swing.plaf.basic.BasicFileChooserUI;
  6. import java.io.File;
  7. import java.util.Vector;
  8.  
  9. class MetalFileChooserUI$DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel {
  10.    // $FF: synthetic field
  11.    MetalFileChooserUI this$0;
  12.    Vector directories;
  13.    File selectedDirectory;
  14.  
  15.    // $FF: synthetic method
  16.    public MetalFileChooserUI$DirectoryComboBoxModel(MetalFileChooserUI this$0) {
  17.       this.this$0 = this$0;
  18.       this.directories = new Vector();
  19.       File[] roots = ((BasicFileChooserUI)this$0).getFileChooser().getFileSystemView().getRoots();
  20.  
  21.       for(int i = 0; i < roots.length; ++i) {
  22.          this.addItem(roots[i]);
  23.       }
  24.  
  25.       this.addItem(((BasicFileChooserUI)this$0).getFileChooser().getCurrentDirectory());
  26.    }
  27.  
  28.    public void addItem(File directory) {
  29.       if (directory != null) {
  30.          if (!this.directories.contains(directory)) {
  31.             this.directories.addElement(directory);
  32.          }
  33.  
  34.          this.setSelectedItem(directory);
  35.       }
  36.  
  37.    }
  38.  
  39.    public void setSelectedItem(Object selectedDirectory) {
  40.       this.selectedDirectory = (File)selectedDirectory;
  41.       ((AbstractListModel)this).fireContentsChanged(this, -1, -1);
  42.    }
  43.  
  44.    public Object getSelectedItem() {
  45.       return this.selectedDirectory;
  46.    }
  47.  
  48.    public int getSize() {
  49.       return this.directories.size();
  50.    }
  51.  
  52.    public Object getElementAt(int index) {
  53.       return this.directories.elementAt(index);
  54.    }
  55. }
  56.